<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>"></base>
<title>用户检索</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript">
    //批量删除
	function confirmMsgDel() {
    	  
    	//得到选中的用户编号列表
    	var ids="";
    	var $userChecked=$('#userTableList').find('input:checked');
    	//至少选择一条记录进行删除
    	if($userChecked.length==0){
    		alert("请至少选择一条记录进行删除");
    		return false;
    	}
    	//遍历选中的用户编号列表  1,2,3,
    	$($userChecked).each(function (){
    		ids+=$(this).val()+",";
    	});
        
    	if(confirm("您确定要删除这些用户吗？")){
    		window.location="<%=basePath%>deleteUsers?ids="+ids;
    	}
	
	}
    
    //用戶修改
    function userUpdate(){
    	//校验
    	//得到选中的用户编号列表
    	var ids="";
    	var $userChecked=$('#userTableList').find('input:checked');
    	//至少选择一条记录进行删除
    	if($userChecked.length==0){
    		alert("请至少选择一条记录进行修改");
    		return false;
    	}else if($userChecked.length>1){
    		alert("只能选择一条记录进行修改");
    		return false;
    	}
    	
    	document.forms[0].action="userInitUpdate";
    	document.forms[0].submit();
    	
    }
	function userOpen() {
		if (confirm("您确定要启用该用户吗?"))
			window.close();
	}
	function userClose() {
		if (confirm("您确定要禁用该用户吗?"))
			window.close();
	}
	function resetPass() {
		if (confirm("重置密码,您确定要恢复初始密码吗?"))
			window.close();
	}
	
    //前后翻页
	function goPage(pn){
		
    	//前一页、后一页、首页、尾页
    	if(null!=pn && pn!=''){
    		document.forms[0].action="getUserInfoList?pn="+pn;
    	}
    	
    	//转到第几页
    	var pageNum=$("#goPageNum").val();
    	if(null!=pageNum && pageNum!=''){
    		document.forms[0].action="getUserInfoList?pn="+pageNum;
    	}
    	
    	document.forms[0].submit();
	}
</script>
<script type="text/javascript">
	$(document).ready(function() {
		$(".click").click(function() {
			$(".tip").fadeIn(200);
		});

		$(".tiptop a").click(function() {
			$(".tip").fadeOut(200);
		});

		$(".sure").click(function() {
			$(".tip").fadeOut(100);
		});

		$(".cancel").click(function() {
			$(".tip").fadeOut(100);
		});

	});
</script>

</head>

<body>
	<div class="place">
		<span>位置：</span>
		<ul class="placeul">
			<li><a href="#">用户管理</a></li>
		</ul>
	</div>
	<form action="getUserInfoList" method="post">
		<div class="formbody">
			<ul class="seachform">
				<li><label>用户编号</label><input name="memId" type="text"
					class="scinput" value="${memId}"/></li>
				<li><label>姓名</label><input name="cname" type="text" class="scinput" value="${cname}"/></li>
				<li><label>&nbsp;</label><input name="" type="submit"
					class="scbtn" value="查询" /></li>
			</ul>
		</div>

		<div class="rightinfo">
			<div class="tools">
				<ul class="toolbar1">
					<li><a href="user/userInfoAdd.jsp"><span><img
								src="images/t01.png" /></span>添加</a></li>
					<li><a href="javascript:userUpdate()"><span><img
								src="images/t02.png" /></span>修改</a></li>
					<li><a href="javascript:confirmMsgDel()"><span><img
								src="images/t03.png" /></span>删除</a></li>
					<li><a href="javascript:userOpen()"><span><img
								src="images/t08.png" height="24" width="24" /></span>启用</a></li>
					<li><a href="javascript:userClose()"><span><img
								src="images/t09.png" height="24" width="24" /></span>禁用</a></li>
					<li><a href="javascript:resetPass()"><span><img
								src="images/t07.png" height="20" width="20" /></span>重置密码</a></li>
				</ul>
			</div>
			<table class="tablelist" id="userTableList">
				<thead>
					<tr class="tablehead">
						<td colspan="11">用户信息列表</td>
					</tr>
				</thead>
				<thead>
					<tr>
						<th><input name="" type="checkbox" value="" /></th>
						<th>用户编号</th>
						<th>姓名</th>
						<th>状态</th>
						<th>注册时间</th>
						<th>最后登录时间</th>
					</tr>
				</thead>
				<tbody>
				 <c:if test="${pageInfo.list!=null}">
				   <c:forEach items="${pageInfo.list}" var="user">
					<tr>
						<td><input name="ids" type="checkbox" value="${user.memId}" /></td>
						<td>${user.memId}</td>
						<td>${user.cname}</td>
						<td>
						  <c:if test="${user.isenable=='T'}">
						        正常
						  </c:if>
						  <c:if test="${user.isenable=='F'}">
						       禁用
						  </c:if>
						</td>
						<td>${user.registerTime}</td>
						<td>${user.lastTime}</td>
					</tr>
					</c:forEach>
                </c:if>
				</tbody>
			</table>
			<div class="pagin">
				<table width="100%" border="0" cellspacing="0" cellpadding="0">
					<tr>
						<td class="STYLE4"><div class="message">
								共<i class="blue">${pageInfo.total}</i>条记录，当前显示第&nbsp;<i class="blue">${pageInfo.pageNum}&nbsp;</i>页
							</div></td>
						<td><table border="0" align="right" cellpadding="0"
								cellspacing="0">
								<tr>
									<td width="45"><img src="images/first.gif" width="33"
										height="20" style="cursor: hand" onclick="goPage(1)" /></td>
									<td width="50"><img src="images/back.gif" width="43"
										height="20" style="cursor: hand" onclick="goPage(${pageInfo.pageNum-1})" /></td>
									<td width="50"><img src="images/next.gif" width="43"
										height="20" style="cursor: hand" onclick="goPage(${pageInfo.pageNum+1})" /></td>
									<td width="40"><img src="images/last.gif" width="33"
										height="20" style="cursor: hand" onclick="goPage(${pageInfo.pages})" /></td>
									<td width="100"><div align="center">
											<span class="STYLE1">转到第 <input name="text"  id="goPageNum"
												type="text" size="4"
												style="height: 16px; width: 35px; border: 1px solid #999999;" />
												页
											</span>
										</div></td>
									<td width="40"><img src="images/go.gif" width="33"
										height="17" style="cursor: hand" onclick="goPage('')" /></td>
								</tr>
							</table></td>
					</tr>
				</table>
			</div>
		</div>
	</form>

	<script type="text/javascript">
		$('.tablelist tbody tr:odd').addClass('odd');
	</script>

</body>
</html>